<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: sitemap_images.xml.php 213 2013-09-22 08:00:34Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 213 $
* 	zuletzt geaendert von:	$Author: peter $
* 	Datum:					$Date: 2013-09-22 08:00:34 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright © since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	© 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	© 2002-2003 osCommerce - www.oscommerce.com
* 	© 2003     nextcommerce - www.nextcommerce.org
* 	© 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');
require(DIR_FS_INC.'inc.get_products_mo_images.php');

header("Content-type: text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'."\n";

$product = $db->db_query("SELECT
								p.products_id,
								p.products_image,
								pd.products_name,
								pd.products_short_description
							FROM
								".TABLE_PRODUCTS." p
								LEFT JOIN ".TABLE_PRODUCTS_DESCRIPTION." AS pd
								ON (pd.products_id = p.products_id AND pd.language_id = '".$_SESSION['languages_id']."') 
							WHERE
								p.products_status = '1'");

$CountryName = $db->db_query("SELECT
									ab.entry_city AS city,
									cnt.countries_name AS country
								FROM
									".TABLE_ADDRESS_BOOK." ab,
									".TABLE_COUNTRIES." cnt
								WHERE
									ab.address_book_id = '1'
								AND
									cnt.countries_id = ab.entry_country_id");

if($product->_numOfRows) {
	while(!$product->EOF) {
		if(!empty($product->fields['products_image'])) {
			echo "\t".'<url>'."\n";

			// URL der Produktseite
			echo "\t\t".'<loc>'.href_link(FILENAME_PRODUCT_INFO, 'products_id='.$product->fields['products_id']).'</loc>'."\n";

			// Image-Block der alle Bilder des Hauptproduktes enthält
			echo "\t\t".'<image:image>'."\n";

			// Die URL des Bilds.
			echo "\t\t\t".'<image:loc>'.HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_POPUP_IMAGES.$product->fields['products_image'].'</image:loc>'."\n";

			// Die Beschriftung des Bilds.
			if(!empty($product->fields['products_short_description']))
				echo "\t\t\t".'<image:caption>'."<![CDATA[".$product->fields['products_short_description']."]]>".'</image:caption>'."\n";

			// Der geografische Standort des Bilds
			echo "\t\t\t".'<image:geo_location>'.$CountryName->fields['city'].','.$CountryName->fields['country'].'</image:geo_location>'."\n";

			// Der Titel des Bilds.
			echo "\t\t\t".'<image:title>'.htmlspecialchars($product->fields['products_name']).'</image:title>'."\n";

			echo "\t\t".'</image:image>'."\n";

			$images = get_products_mo_images($product->fields['products_id']);
			if($images) {
				for($i = 0; $i < sizeof($images); $i++) {
					echo "\t\t".'<image:image>'."\n";

					echo "\t\t\t<image:loc>".HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_POPUP_IMAGES.$images[$i]['image_name']."</image:loc>\n";

					// Die Beschriftung des Bilds.
					if(!empty($product->fields['products_short_description']))
						echo "\t\t\t".'<image:caption>'."<![CDATA[".$product->fields['products_short_description']."]]>".'</image:caption>'."\n";

					// Der geografische Standort des Bilds
					echo "\t\t\t".'<image:geo_location>'.$CountryName->fields['city'].','.$CountryName->fields['country'].'</image:geo_location>'."\n";

					// Der Titel des Bilds.
					echo "\t\t\t".'<image:title>'.htmlspecialchars($product->fields['products_name']).'</image:title>'."\n";

					echo "\t\t".'</image:image>'."\n";
				}
			}
			echo "\t".'</url>'."\n";
		}
		$product->MoveNext();
	}
}
echo "</urlset>";